#include<iostream>
using namespace std;
class fri1
{
    friend class fri2;//fri2是fri1的友元类
public:
    fri1():x(0)
    {
    }
    void printt() const
    {
        cout<<"fri1里的 x: "<<x<<endl;
    }
private:
    int x;
};

class fri2
{
public:
    fri2():y(9)
    {
    }
    void print(fri1& f1,int x) const
    {
        cout<<"fri2里的 y: "<<y<<endl;
        f1.x = x;//修改f1中x的值
        f1.printt();//访问f1的成员函数
    }
private:
    int y;
};

int main()
{
    fri1 friend1;
    cout<<"创建fri1对象friend1, x的值为: "<<endl;
    friend1.printt();
    fri2 friend2;
    cout<<"使用friend2.print(fri1,10)后： "<<endl;
    friend2.print(friend1, 10);
    return 0;
}
